<?php 
namespace Admin\Controller;
use Common\Controller\AdminBaseController;

class ColumnsController extends AdminBaseController{

	public function glist(){
		$colu = D('columns');
		$list = $colu->colulist(2,'*','id');
		$list = _getTree($list['data'],0,0,'&nbsp;&nbsp;|--');
		$this -> assign('list',$list);
		$this -> display();
	}
	
	public function alist(){
		$colu = D('columns');
		$list = $colu->colulist(1,'*','id');
		$list = _getTree($list['data'],0,0,'&nbsp;&nbsp;|--');
		$this -> assign('list',$list);
		$this -> display();
	}

	public function goodadd(){
		$pid = I('get.pid/d',0);//此pid 是前台传过来的id
		$data = ['pid' => $pid];
		$this -> assign('resultadd',$data);
		$this -> display();
	}

	public function artadd(){
		$pid = I('get.pid/d',0);//此pid 是前台传过来的id
		$data = ['pid' => $pid];
		$this -> assign('resultadd',$data);
		$this -> display();
	}

	public function save(){
		if(IS_POST || IS_AJAX){
			$colu = D('columns');
			$result = $colu -> addCol(I('post.'));
			$this -> ajaxReturn($result);
		}	
	}

	public function gedit(){
		if(IS_GET){
			$result = D('columns') -> editlist(I('get.id/d',0),'*');
			$this -> assign('resultedit',$result['data'][0]);
			$this -> display('Columns_goodadd');
		}
	}

	public function aedit(){
		if(IS_GET){
			$result = D('columns') -> editlist(I('get.id/d',0),'*');
			$this -> assign('resultedit',$result['data'][0]);
			$this -> display('Columns_artadd');
		}
	}

	public function del(){
		if(IS_POST){
			$result = D('columns') -> Delcolu(I('post.id/d',0));
			$this -> ajaxReturn($result);
		}
	}

	public function Alterstate(){
		if(IS_POST){
			$result = D('columns') -> Alterstate(I('post.id/d',0));
			$this -> ajaxReturn($result);
		}

	}

}